import { defineComponent } from 'vue'
import { NCard, NTabPane, NTabs, useMessage } from 'naive-ui'
import infoHandle from '@/views/integration/assets/infoHandle'
import infoLineage from '@/views/integration/assets/infoLineage'
import infoSchedule from '@/views/integration/assets/infoSchedule'
import { useRouter } from 'vue-router'

const assetsInfo = defineComponent({
  name: 'assetsInfo',
  components: {
    infoHandle,
    infoLineage,
    infoSchedule
  },
  setup() {
    const router = useRouter()
    const message = useMessage()

    const verifyParams = function () {
      if (
        !router.currentRoute.value.query.tableName ||
        !router.currentRoute.value.query.schemaName
      ) {
        message.info('参数错误')
        router.push('/integration/assets')
      }
    }

    verifyParams()
    return {
      verifyParams,
      router,
      message
    }
  },
  render() {
    return (
      <NCard>
        <NTabs type='line' animated>
          <NTabPane name='info' tab='详细信息'>
            <infoHandle></infoHandle>
          </NTabPane>
          <NTabPane name='lineage' tab='血缘关系'>
            <infoLineage></infoLineage>
          </NTabPane>
          <NTabPane name='schedule' tab='任务信息'>
            <infoSchedule></infoSchedule>
          </NTabPane>
        </NTabs>
      </NCard>
    )
  }
})

export default assetsInfo
